package library.operation;

import library.Book;
import library.ListBook;

import java.util.Scanner;
//添加图书操作类
public class AddOperation implements IOperation{
    @Override
    public void work(ListBook listBook) {
        System.out.println("开始增加图书！");
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入图书名：");
        String name = scanner.next();
        System.out.print("请输入作者姓名：");
        String author = scanner.next();
        System.out.print("请输入图书价格：");
        double price = scanner.nextDouble();
        System.out.print("请输入图书类型：");
        String type = scanner.next();
        Book book = new Book(name, author, price, type);
        int size = listBook.getSize();
        listBook.setBook(size, book);
        //增加后，书的总量增加1本
        listBook.setSize(size + 1);
        System.out.println("增加图书成功！");
    }
}
